package tools.Reflection;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import m2.component.Component;
@SuppressWarnings("all")
public class OnComponent {

	/**
	 * 
	 * @param component
	 * @return
	 */
	public static Component getComponent(String component){
		Component comp = null;		
		Class tmpClass;
		try {
			tmpClass = Class.forName(component);	
			Method factoryMethod = tmpClass.getDeclaredMethod("getInstance");
			comp = (Component)factoryMethod.invoke(null, null);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}	
		
		return comp;
	}
}
